#include <cstdio>

/**
 * Luogu P1134 Last Non-Zero Digit of a Factorial
 * Since this problem only requires last non-zero digit, high precision integer
 * is not necessary.
 * Be careful of multiplication like 12 * 15 = 180 vs 2 * 5 = 10.
 */

int pow2[4]{2, 4, 8, 6};

int main() {
    int n;
    scanf("%d", &n);
    long long n2 = 0, n5 = 0;
    int fac = 1;
    for (int i = 2; i <= n; i++) {
        int v = i;
        while (v % 2 == 0) {
            v /= 2;
            n2++;
        }
        while (v % 5 == 0) {
            v /= 5;
            n5++;
        }
        fac = (fac * v) % 10;
    }
    if (n2 < n5)
        fac = (fac * 5) % 10;
    else if (n2 > n5)
        fac = (fac * pow2[(n2 - n5 - 1) % 4]) % 10;
    printf("%d\n", fac);
}